/*
* 微信接口promise化
* */
module.exports = {
    /*
    * 小程序日志
    * */
    getLogManager: function (type, value) {
        const logger = wx.getLogManager();
        switch (type) {
            case "debug":
                logger.debug(value);
                break
            case "info":
                logger.info(value);
                break
            case "log":
                logger.log(value);
                break
            case "warn":
                logger.warn(value);
                break
            default:
                break
        }
    },

    /*
    * 设置缓存
    * */
    setStorage: function (key, data) {
        return new Promise(function (resolve, reject) {
            wx.setStorage({
                key: key,
                data: data,
                success: function () {
                    resolve()
                },
                fail: function (err) {
                    reject(err)
                }
            })
        })
    },

    /*
    * 移除缓存
    * */
    removeStorage: function (key) {
        return new Promise(function (resolve, reject) {
            wx.removeStorage({
                key: key,
                success () {
                    resolve()
                },
                fail: function (err) {
                    reject(err)
                }
            })
        })
    }

}